import request from '../utils/request'
import qs from 'qs'

// 轮播
const rollingImg = (params = {}) => request.get('/banner/list', { params }) 
// 商品分类
const goodsCategory = (params = {}) => request.get('/shop/goods/category/all', { params }) 
// 商品列表
const goodsList = (params = {}) => request.post('/shop/goods/list/v2', qs.stringify(params)) 
// 详情
const goodsDetail = (params = {}) => request.get('/shop/goods/detail', { params }) 
// 登录
const userLogin = (params = {}) => request.post('/user/username/login', qs.stringify(params)) 
// 注册
const userRegister = (params = {}) => request.post('/user/username/register', qs.stringify(params)) 
// 加购
const addCart = (params = {}) => request.post('/shopping-cart/add', qs.stringify(params)) 
// 是否收藏
const whetherFavor = (params = {}) => request.get('/shop/goods/fav/check', { params }) 
// 加入收藏
const addFavor = (params = {}) => request.post('/shop/goods/fav/add', qs.stringify(params)) 
// 收藏列表
const listFavor = (params = {}) => request.post('/shop/goods/fav/list', qs.stringify(params)) 
// 删除收藏
const delfavor = (params = {}) => request.post('/shop/goods/fav/delete', qs.stringify(params)) 
// 购物车列表
const cartList = (params = {}) => request.get('/shopping-cart/info', { params }) 
// 购物车单个商品数量
const setGoodsNum = (params = {}) => request.post('/shopping-cart/modifyNumber', qs.stringify(params)) 
// 购物车单个商品选中情况
const setGoodsSelect = (params = {}) => request.post('/shopping-cart/select', qs.stringify(params)) 
// 删除购物车商品
const delGoods = (params = {}) => request.post('/shopping-cart/remove', qs.stringify(params)) 
// 获取用户信息
const getUsermsg = (params = {}) => request.get('/user/detail', { params }) 
// 修改用户信息
const changeUsermsg = (params = {}) => request.post('/user/modify', qs.stringify(params)) 
// 上传头像
const uploadImg = (params) => request.post('/dfs/upload/file',  params) 


export {
  rollingImg,
  goodsCategory,
  goodsList,
  goodsDetail,
  userLogin,
  userRegister,
  addCart,
  whetherFavor,
  addFavor,
  cartList,
  setGoodsNum,
  setGoodsSelect,
  delGoods,
  getUsermsg,
  changeUsermsg,
  uploadImg,
  listFavor,
  delfavor
}